package com.atguigu.boot2.process;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Author yanglin [2533188365@qq.com]
 * @Create 2025-02-19 15:48
 * @Description:
 */
@Component
public class CustomBeanPostProcessor implements BeanPostProcessor {
    /**
     *
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if ("hello".equals(beanName)){
            System.out.println("需要在hello初始化之前执行的内容");
        }
        return bean;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("hello".equals(beanName)){
            System.out.println("需要在hello初始化之后执行的内容");
        }
        return bean;
    }
}
